<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>.capture 捕获事件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>

<body>
    <div id='app'>
        <!-- 捕获事件：嵌套两三层父子关系，然后所有都有点击事件，点击子节点，就会触发从外至内  父节点-》子节点的点击事件 -->
        <!-- 在有上下级关系是，不添加capture属性是 点击会从内到外的实现 -->
        <div @click.capture="outer" style="height: 100px; background-color: aquamarine;">
            <div @click.capture="middle" style="height: 50px; background-color: rgb(1, 163, 109);">
                <div @click.capture="inner" style="border: red 1px solid; background-color: rgb(0, 82, 55);">
                    <button @click.capture="but">点我(^_^)</button>
                </div>
            </div>
        </div>
        <p>{{message}}</p>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: '测试点击事件'
            },
            methods: {
                outer: function() {
                    console.log('这里是outer外部事件');
                    this.message = '这里是outer外部事件';
                },
                middle: function() {
                    console.log('这里是middle中间事件');
                    this.message = '这里是middle中间事件';
                },
                inner: function() {
                    console.log('这里是inner内部事件');
                    this.message = '这里是inner内部事件';
                },
                but: function() {
                    console.log('这里是but按钮事件');
                    this.message = '这里是but按钮事件';
                }
            }
        })
    </script>
</body>

</html>